package com.atguigu.gmall.task.t1;

import com.atguigu.gmall.rabbitmq.config.RabbitConst;
import com.atguigu.gmall.rabbitmq.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author: Mamba
 * @version: 1.0
 * @Time: 2021/1/17 17:33
 * @Description:
 */
@Component
@EnableScheduling//开启定时器
public class Task1 {
    @Autowired
    private RabbitService rabbitService;
    //执行  每天晚上半夜12点执行
    //@Scheduled(cron = "0 0 0 * * ?")
    @Scheduled(cron = "0/5 * * * * ?")
    public void task1(){
        System.out.println("每5s执行了任务");
        //100行 将DB数据导入缓存
        rabbitService.sendMessage(RabbitConst.EXCHANGE_DIRECT_TASK,
                RabbitConst.ROUTING_TASK_1,"随便发什么都可以");//闹铃
    }
}
